<template>
    <div>
      <span class="el-descriptions__title">跟踪记录</span>
      <div class="el-input--mini" v-for="item in trackList">
        <el-row v-if="item.operParam.trackStatus">
          <el-col :span="8"><span>跟进状态</span></el-col>
          <el-col :span="16"><span>{{selectDictLabel(dict.type.track_status, item.operParam.trackStatus)}}</span></el-col>
        </el-row>
        <el-row v-if="item.operParam.nextTime">
          <el-col :span="8"><span>下次跟进时间</span></el-col>
          <el-col :span="16"><span>{{parseTime(item.operParam.nextTime)}}</span></el-col>
        </el-row>
        <el-row v-if="item.operParam.keyItems">
          <el-col :span="8"><span>沟通重点</span></el-col>
          <el-col :span="16">
               <span v-for="keyId in (item.operParam.keyItems.split(','))" :key="keyId" class="cus-tag-box">
                 {{ selectDictLabel(dict.type.communication_point, keyId)}}
               </span>
          </el-col>
        </el-row>
        <el-row v-if="item.operParam.level">
          <el-col :span="8"><span>意向等级</span></el-col>
          <el-col :span="16"><span>{{selectDictLabel(dict.type.clues_level, item.operParam.level)}}</span></el-col>
        </el-row>
        <el-row v-if="item.operParam.subject">
          <el-col :span="8"><span>意向学科</span></el-col>
          <el-col :span="16"><span>{{selectDictLabel(dict.type.course_subject, item.operParam.subject)}}</span></el-col>
        </el-row>
        <el-row v-if="item.operParam.falseReason">
          <el-col :span="8"><span>伪线索原因</span></el-col>
          <el-col :span="16"><span>{{selectDictLabel(dict.type.reasons_for_reporting, item.operParam.falseReason)}}</span></el-col>
        </el-row>
        <el-row>
          <el-col :span="8"><span>沟通内容</span></el-col>
          <el-col :span="16"><span>{{item.operParam.record}}</span></el-col>
        </el-row>
        <el-row>
          <el-col :span="8"><span>记录人</span></el-col>
          <el-col :span="16"><span>{{item.operName}}</span></el-col>
        </el-row>
        <el-row>
          <el-col :span="8"><span>记录时间</span></el-col>
          <el-col :span="16"><span>{{item.operTime}}</span></el-col>
        </el-row>
        <hr>
      </div>
    </div>
</template>

<script>
  import { listBusinessTrack } from "@/api/crm/businessTrack";
    export default {
        name: "track-list",
      props: {
         search: {
           type: String,
           default: '商机跟进记录'
         },
        id: {
           type: [Number, String],
           default: 0
        }
      },
      dicts: ['track_status','communication_point','clues_level','course_subject','reasons_for_reporting'],
      data() {
          return {
            trackList: [],
          }
      },
      created() {
          this.getTrackList();
      },
      methods: {
        getTrackList() {
          listBusinessTrack({'title': this.search}).then(resp=>{
            let rows = resp.rows;
            if(rows && rows.length > 0) {
              this.trackList = rows.map(item => {
                item.operParam = JSON.parse(item.operParam)
                return item
              }).filter(item => item.operParam.id == this.id);
            }
          })
        },
      }
    }
</script>

<style scoped>

</style>
